import { message } from "antd";
import axios from "axios";

const authRequest = axios.create({
  baseURL: '/acl'
})

// 响应拦截器
authRequest.interceptors.response.use(({ data }) => {
  if (data.code === 200) return data
  message.error(data.message)
  return new Promise(() => { })
})

// 请求拦截器
authRequest.interceptors.request.use((config: any) => {
  if (localStorage.getItem("token")) {
    config.headers.token = localStorage.getItem("token");
  }
  return config;
})

export default authRequest
